<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template v-slot:before>
        <zlrt-search :p="ctx">
          <!-- <template #tenantId>
            <el-select v-model="ctx.filter.tenantId" placeholder="请选择租户">
              <el-option v-for="ite in tenantOptions" :key="ite.id" :label="ite.name" :value="ite.id" />
            </el-select>
          </template> -->
          <template #name>
            <el-input v-model="ctx.otherFilter.name" placeholder="请输入项目名称" />
          </template>
        </zlrt-search>
        <div class="tool-bar">
          <el-button type="danger" v-hasPermit="['wms:project:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-upload style="display: inline-block;position: relative;top: 4px;margin-right: 10px;"
                v-model:file-list="importFiles" action="#"
                :http-request="options => ctx.other.upload(options)" :show-file-list="false" :limit="1">
                <el-button type="warning" v-hasPermit="['wms:project:upload']" :loading="importLoading" icon="Upload"
                @click="ctx.other.upload()">
                导入排产计划
              </el-button>
            </el-upload>
            <el-button type="success" v-hasPermit="['wms:project:list']" :loading="ctx.exportLoading" icon="Download"
              @click="ctx.export()">
              导出
            </el-button>
            <el-button type="primary" v-hasPermit="['wms:project:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button>
          </span>
        </div>
      </template>
      <template v-slot:productCompleteDate="scope">
        {{ ctx.other.formatDate(scope.row.productCompleteDate) }}
      </template>
      <template v-slot:planCompleteDate="scope">
        {{ ctx.other.formatDate(scope.row.planCompleteDate) }}
      </template>
      <template v-slot:disabled="scope">
        <el-tag :type="scope.row.disabled === 4 ? 'danger' : 'success'">{{ ctx.other.getStatusname(scope.row.disabled) }}
        </el-tag>
      </template>
      <template v-slot:operation="scope">
        <el-button type="primary" v-hasPermit="['wms:project:detail']" link size="small" icon="Link" :loading="requirementCtx.loading"
          @click="ctx.other.getInventoryDetail(scope.row)">
          物料明细
        </el-button>
        <el-button type="primary" v-hasPermit="['wms:project:save']" link size="small" icon="Edit"
          @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button type="danger" v-hasPermit="['wms:project:del']" link size="small" icon="Delete"
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template v-slot:after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="600px" append-to-body
          :close-on-click-modal="false" @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <!-- <el-form-item label="租户" prop="tenantId">
              <el-select v-model="ctx.editData.tenantId" placeholder="请选择租户">
                <el-option v-for="ite in tenantOptions" :key="ite.id" :label="ite.name" :value="ite.id" />
              </el-select>
            </el-form-item> -->
            <el-form-item label="项目名称" prop="name">
              <el-input v-model="ctx.editData.name" placeholder="请输入项目名称" />
            </el-form-item>
            <el-form-item label="合同号" prop="originalNo">
              <el-input v-model="ctx.editData.originalNo" placeholder="请输入合同号" />
            </el-form-item>
            <el-form-item label="生产完成日期" prop="productCompleteDate">
              <el-date-picker v-model="ctx.editData.productCompleteDate" type="date" placeholder="请选择生产完成日期"/>
            </el-form-item>
            <el-form-item label="计划完成日期" prop="planCompleteDate">
              <el-date-picker v-model="ctx.editData.planCompleteDate" type="date" placeholder="请选择计划发货日期"/>
            </el-form-item>
            <el-form-item label="状态" prop="disabled">
              <el-select v-model="ctx.editData.disabled" placeholder="请选择状态">
                <el-option v-for="ite in disabledOptions" :key="ite.value" :label="ite.label" :value="ite.value" />
              </el-select>
            </el-form-item>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="ctx.editVisible = false">取消</el-button>
              <el-button type="primary" @click="ctx.save()">确定</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>

    <el-dialog v-model="requirementCtx.dialogVisible" title="物料明细" width="90%" append-to-body top="3vh"
      :close-on-click-modal="false" @close="ctx.closeEdit()">
      <zlrt-table :p="requirementCtx">
        <template #inventoryList="scope">
          {{ requirementCtx.other.getInventoryNum(scope.row.inventoryList) }}
        </template>
        <template #isCheck="scope">
          <el-switch v-model="scope.row.isCheck" :active-value="true" :inactive-value="false" active-color="#13ce66"
            @change="requirementCtx.other.changeCheck(scope.row)" />
        </template>
        <template #numberCheck="scope">
          <el-input v-model="scope.row.numberCheck" placeholder="请输入提醒数量" @blur="requirementCtx.other.changeNumberCheck(scope.row)"/>
        </template>
      </zlrt-table>
    </el-dialog>

  </u-container-layout>
</template>

<script lang="ts" src="./project">
</script>
